import { Controller } from 'egg';
// const { userMsg } = require('../middleware/user/requestUserMsg.js');

export default class CrawlerController extends Controller {

  /**
   * @api {post} crawler/setting 爬虫设置
   *  
   * @apiName setting
   * @apiGroup Crawler
   * @apiDescription 爬虫设置
   * 
   * @apiParam {String} [visitLimit] 是否开启用户访问次数限制
   * @apiParam {Int} [visitLimitPerDays] 限制单用户的访问次数
   * @apiParam {Boolean} [redundantDom] 是否开启冗余节点混淆解析内容
   * @apiParam {Boolean} [ipDetect] 是否开启ip检测
   * @apiParam {Boolean} [httpDetect] 是否开启HTTP头部检测
   * @apiParam {Boolean} [downLimit] 是否开启用户下载次数限制
   * @apiParam {Int} [downLimitPerDays] 开启用户下载之后用户限制下载数
   */
  public async crawlerSetting(ctx) {
    let body = ctx.request.body;
    await ctx.model.Crawler.create(body);
    ctx.response.body = {
      code: 200,
      status: '成功'
    };
  }

}
